<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/icon.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/btn.css" />
<link rel="Stylesheet" href="${aier_css_url}social/module/emotion.css" />
<link rel="Stylesheet" href="${aier_css_url}social/module/homeside.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/userMessage/usermessage.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/xxs.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}emotion/xxsemotion.2.js"></script>
<script type="text/javascript" src="${aier_js_url}trantime/jquery-aier.js"></script>

</head>
<body>

	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user" executeResult="true"></s:action>
	<!-- 顶栏结束 -->

	<!-- 主区域 -->


	<div class="window-content">

		<!-- wrap  -->
		
		<div class="wrap wrap-message wrap-tri-col clearfix">
			<!-- 主侧栏 -->
			<s:action name="usermessage_msgSide" namespace="/user" executeResult="true"></s:action>

			<!-- 主区域 (右  -->
			<div class="message-main clearfix">
				<div class="message-stream msg-stream-special msg-special">
				

					<div class="title msg-title">
						<div class="group">
							<a class="current" id="tagXXS">@我的新鲜事</a>
							<span>|</span>
							<a id="tagComment">@我的评论</a>
						</div>
					</div>
					
					<!-- start @了我的新鲜事-->
					<div class="msg-about-weibo" id="msgSpecialXXS">

					</div>
					<!-- end  @了我的微博 -->
					
					
					<!-- start @了我的评论 -->
					<div class="msg-at-comment" id="msgSpecialComment" style="display: none;">
				
					</div>
					<!-- end @了我的评论 -->
					
					<div id = "page"></div>
					
				</div>


                <!-- 右栏 -->
                <s:action name="userhomecomm_homeRight" namespace="/user" executeResult="true"></s:action>
			</div>

			<!-- 回到顶部 -->
			<s:action name="userhomecomm_backToTop" namespace="/user" executeResult="true"></s:action>
				




		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
		
		<!-- 转发这条新鲜事 -->
	    <div class="dialog-xxs-forward" id="dialogForward" title="转发" style="display:none;">
	        <div class="box-textarea">
	            <textarea id="forward" cols="30" rows="10"></textarea>
	        </div>
	    
	        <div class="submit-bar">
	            <div class="left">
	                <div class="btn-emotion-forward"></div>
	                <div class="select-comment">
	                    <div>
	                        <label>
	                            <input type="checkbox" id = "commentFlag">
	                            同时评论给该作者
	                        </label>
	                    </div>
	                </div>
	            </div>
	        </div>
	    
	    </div>
	    <div id="deleteConfirm" style="display: none;" title="删除">
        <p>你确定要删除这条新鲜事吗?</p>
    </div>
	    
	</div>


<script type="text/javascript">
var fpage = 1;      // 微博的当前页
var cpage = 1;      // 评论的当前页
var page_size = 10; // 每页的记录数


// 预览图和完整图切换
$('.zoom-out,.xxs-btn-collapse').click(function(){
	$(this).parents('.xxs-extend').css('display','none')
	.prev('.xxs-media-pre').css('display','block');
});
$('.zoom-in').click(function(){
	$(this).parents('.xxs-media-pre').css('display','none')
	.next('.xxs-extend').css('display','block');
});

function emotionClick(){
    // 插入表情 - 发表对微博的评论
    $('.submit-bar>.btn-emotion').click(function(){
    
        $(this).sinaEmotion({
            emotionUrl: '${aier_js_url}trantime/emotions.js',
            target : $(this).closest('.input-box').find('textarea')
        });
    });
}

function openCCClick(){
    // 插入表情 - 发表对评论的回复
    $('.cc-submit-bar>.btn-emotion').click(function(){
         $(this).sinaEmotion({
            emotionUrl: '${aier_js_url}trantime/emotions.js',
            target : $(this).closest('.comment-comment').find('textarea')
        });
    });
}


// @我的微博 和 @我的评论 切换
$('#tagXXS').click(function(){
	if (!$(this).hasClass('current')) {
		$('#tagComment').removeClass('current');
		$('#msgSpecialComment').hide();
		$(this).addClass('current');
		searchFresh();
		$('#msgSpecialXXS').show();
	}
});

$('#tagComment').click(function(){
	if (!$(this).hasClass('current')) {
		$('#tagXXS').removeClass('current');
		$('#msgSpecialXXS').hide();
		$(this).addClass('current');
		searchSComment();
		$('#msgSpecialComment').show();
	}
});

    $(document).ready(function() {
        searchFollowGroup();
        searchFresh();
    });
    
    // 获取关注分组
    function searchFollowGroup() {
        var fun=function(data){
            if(data.s==1){
                var c = "";
                for (var i=0;i<data.fgList.length;i++) {
                    if (data.fgList[i].name == "特别关注") {
                        c += "<div class='tab-normal'><a class='btn' href='${aier_url}user/userhomeforums_homeForums.shtml?fgid="+data.fgList[i].fgid+"'><em class='icon-1 icon-1-teguan'></em><span>"+data.fgList[i].name+"</span></a></div>";
                    } else {
                        c += "<div class='tab-normal'><a class='btn' href='${aier_url}user/userhomeforums_homeForums.shtml?fgid="+data.fgList[i].fgid+"'><em class='icon-1 icon-1-weifen'></em><span>"+data.fgList[i].name+"</span></a></div>";
                    }
                    
                }
                $("#group").html(c);
                
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}usermyfollow_searchFollowGroup${aier_suffix}"),
             fun,{
        });
    }
    
    // 获取@我的微博列表
    function searchFresh() {
        var fun=function(data){
               if(data.s==1){
                   $("#msgSpecialXXS").html("");
                   appendFresh(data.freshList,data.uid);
                   // 更新分页显示
                   fpage = data.page;
                   toLoadPage(fpage, page_size, data.page_count, data.count, "page", "appendFresh", null, null);
                   if (data.count == 0) {
                       $("#page").css("display","none");
                   } else {
                       $("#page").css("display","block");
                   }
                   
               } else {
                   $().message("获取新鲜事失败，请稍后再试！"); 
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}usermessage_searchSpecialFresh${aier_suffix}"),
                fun,{
                    "page":fpage,
                    "page_size":page_size
           });
    }
    
    function appendFresh(freshList,uid) {
        var html = "";
        if (freshList == null || freshList.length == 0) {
            html += '<div class="msg-at-comment-num">暂时没有新鲜事@你</div>';
        } else {
            html += '<div class="msg-at-comment-num">共'+freshList.length+'条</div>';
            html += '<div class="message-stream-list child-message-list clearfix">';
            for (var i=0; i<freshList.length; i++) {
	            var fresh = freshList[i];
	            
	            html += "<div class='xxs-item xxs-with-avatar' data-xxsid = "+fresh.fid+" data-xxuid="+fresh.uid+">";
	            // 头像
	            html += "<div class='xxs-avatar'><a href='${aier_url}user/uccomm_userCenter.shtml?in_uid="+fresh.uid+"'><img src=${get_picturl_url}small/"+fresh.headimg+" alt=''></a></div>";
	            // 昵称
	            html += "<div class='xxs-detail'><div class='xxs-name'><a>"+fresh.nickname+"</a></div>";
	            // 内容
	            html += "<div class='xxs-text'>"+fresh.content+"</div>";
	            
	            // 有图片
	            if (!isnull(fresh.img)) {
	                html += "<ul class='xxs-media-pre xxs-single-img' style=''><li><div><img class='zoom-in' src=${fresh_get_url}small/"+
	                    fresh.img+" alt=''></div></li></ul><div class='xxs-box xxs-extend' style='display:none'><div class='top-function clearfix'><a class='btn-collapse'><i class='icon-1 icon-1-collapse'></i><span>收起</span></a></div><div class='media'><img class='zoom-out' src=${fresh_get_url}big/"+
	                    fresh.img+" alt=''></div></div>";
	            }
	            // 转发
	            if (fresh.type == 1) {
	                var fr = fresh.fresh;
	                html += "<div class='xxs-box xxs-box-has-o' style=''><div class='xxs-name-o'><a href='${aier_url}user/uccomm_userCenter.shtml?in_uid="+fr.uid+"'>"+fr.nickname+"</a></div><div class='text'>"+fr.content+"</div>";
	                // 有图片
	                if (!isnull(fr.img)) {
	                    html += "<ul class='xxs-media-pre xxs-single-img' style=''><li><div><img class='zoom-in' src=${fresh_get_url}small/"+
	                        fr.img+" alt=''></div></li></ul><div class='xxs-extend' style='display:none'><div class='top-function clearfix'><a class='btn-collapse'><i class='icon-1 icon-1-collapse'></i><span>收起</span></a></div><div class='media'><img class='zoom-out' src=${fresh_get_url}big/"+
	                        fr.img+" alt=''></div></div>";
	                }
	                html += "<div class='xxs-function-o clearfix'><div class='xxs-handle'>";
	                if (fr.pcount == 0) {
	                    html += '<a class="btn xxs-like-btn"><em class="icon-1 icon-1-like"></em></a>';
	                } else {
	                    html += '<a class="btn xxs-like-btn"><em class="icon-1 icon-1-like"></em>('+fr.pcount+')</a>';
	                }
	                
	                if (fr.tcount == 0) {
	                    html += "<span>|</span> <a>转发</a> <span>|</span>";
	                } else {
	                    html += "<span>|</span> <a>转发("+fr.tcount+")</a> <span>|</span>";
	                }
	            
	                html += '<a>收藏</a>';
	                if (fr.ccount == 0) {
	                    html += "<span>|</span> <a>评论";
	                } else {
	                    html += "<span>|</span> <a>评论("+fr.ccount+")";
	                }
	                html += "</a></div><div class='xxs-from'><a>"+fr.cdate.split("T")[0]+" "+fr.cdate.split("T")[1]+"</a></div></div></div>";
	                
	            }
	            
	            // 底部功能
	            html += "<div class='xxs-function clearfix'><div class='xxs-handle'>";
	            
	            if (fresh.pflag == 1) {
	                if (fresh.pcount == 0) {
	                    html += '<a class="btn xxs-like-btn" ><em class="icon-1 icon-1-like has-liked"></em></a>';
	                } else {
	                    html += '<a class="btn xxs-like-btn" ><em class="icon-1 icon-1-like has-liked"></em>('+fresh.pcount+')</a>';
	                }
	                
	            } else {
	                if (fresh.pcount == 0) {
	                    html += '<a class="btn xxs-like-btn" ><em class="icon-1 icon-1-like"></em></a>';
	                } else {
	                    html += '<a class="btn xxs-like-btn" ><em class="icon-1 icon-1-like"></em>('+fresh.pcount+')</a>';
	                }
	            }
	            
	            if (fresh.tcount == 0) {
	                html += '<span>|</span> <a class="btn-forward">转发</a><span>|</span>';
	            } else {
	                html += '<span>|</span> <a class="btn-forward">转发('+fresh.tcount+')</a><span>|</span>';
	            }
	        
	            if (fresh.fflag == 1) {
	                html += '<a class="btn-favourite has-fav">取消收藏</a>';
	            } else {
	                html += '<a class="btn-favourite">收藏</a>';
	            }
	            
	            if (fresh.ccount == 0) {
	                html += "<span>|</span> <a class='btn-xxs-comment'>评论";
	            } else {
	                html += "<span>|</span> <a class='btn-xxs-comment'>评论("+fresh.ccount+")";
	            }
	            
	            html += "</a></div><div class='xxs-from'><a>"+fresh.cdate.split("T")[0]+" "+fresh.cdate.split("T")[1]+"</a></div></div>";
	            
	            html += '<div class="xxs-comment"  style="display:none;"><div class="input-box"><div class="textarea-bar"><textarea class="comment-textarea" data-id="123"></textarea></div>';
	            html += '<div class="submit-bar clearfix"><div class="btn-emotion"><a href="javascript:void(0);" class="icon-1 icon-1-emotion btn-emotion"></a></div><div class="left-reblog"><div class="select"><label><input type="checkbox">同时转发到我的新鲜事</label></div>';
	            
	            if (fresh.type == 1) {
	                html += '<div class="select"><label><input type="checkbox">同时评论给原作者</label></div>';
	            }
	            html += '</div><div class="right-submit"><a class="btn-orange-2"><span>评论</span></a></div></div></div>';
	            
	            html += '<div class="xxs-comment-list" id = "comment'+fresh.fid+'"></div></div></div>';
	            
	            
	            if (uid == fresh.uid) {
	                // 删除该条新鲜事 
	                html += "<div class='xxs-screen'><a href='javascript:void(0);' class='btn-screen-delete' onclick='deleteFresh("+fresh.fid+");'>x</a></div>";
	            }
	            html += "</div>";
	            
	        }
	        html +="</div>";
        }
        $("#msgSpecialXXS").html(html);
        
        emotionClick();
        // 解析表情
        $('.text,.xxs-text').each(function() {
            $(this).tranText({
                emotionUrl:'${aier_js_url}trantime/emotions.js'
            });
        });
       
        // 预览图和完整图切换
        //缩小
        $('.zoom-out,.btn-collapse').click(
                function() {
                    $(this).parents('.xxs-extend').css('display', 'none').prev('.xxs-media-pre').css('display', 'block');
                });
        //放大
        $('.zoom-in').click(
            function() {
                $(this).parents('.xxs-media-pre').css('display', 'none').next('.xxs-extend').css('display', 'block');
            });
         
         // 称赞或取消赞（ptype为0赞1取消赞）
        $('.xxs-function .xxs-like-btn').click(function(){
            var thisobj = $(this);
            var ptype;
            if( thisobj.children('em').hasClass('has-liked') ){
                ptype = 1;
            } else {
                ptype = 0;
            }
            var fid = thisobj.closest('.xxs-item').attr('data-xxsid');
            var fun=function(data){
                if(data.s==1){
                 
                    if (ptype == 0) {
                        // 赞
                        if (data.pcount != null && data.pcount!=0) {
                            thisobj.html('<em class="icon-1 icon-1-like has-liked"></em>('+data.pcount+')');
                        } else {
                            thisobj.html('<em class="icon-1 icon-1-like has-liked"></em>');
                        }
                    } else {
                        // 取消赞
                        if (data.pcount != null && data.pcount!=0) {
                            thisobj.html('<em class="icon-1 icon-1-like"></em>('+data.pcount+')');
                        } else {
                            thisobj.html('<em class="icon-1 icon-1-like"></em>');
                        }
                    }
                }
            };
            exeAjax(
                 ajaxUrl("${aier_url}${aier_urijs}userhomeforums_praiseFresh${aier_suffix}"),
                 fun,{
                     "fid":fid,
                     "ptype":ptype
            });
        });
        
        // 转发
        $('.btn-forward').click(function(){
            var fid = $(this).closest('.xxs-item').attr('data-xxsid');
            var thisobj = $(this);
            $('#dialogForward').dialog({
                //背景变暗
                modal: true,
                autoOpen : false,
                show : "fade",
                   hide : "fade",
                width : "400",
                height : "400",
                buttons: {
                    "确定": function() {
                        // 转发新鲜事
                        var content = $("#forward").val();
                        if (isnull(content)) {
                            content = "转发";
                        } 
                        var cflag = 0;
                        if ($('#commentFlag').attr("checked") == "checked") {
                            cflag = 1;
                        }
                        var fun=function(data){
                               
                               if(data.s==1){
                                   // 修改转发的次数
                                   thisobj.html('转发('+data.tcount+')');
                                   $("#forward").val("");
                                   $("#commentFlag").attr("checked",false);
                                   $('#dialogForward').dialog('close');
                               } else {
                                   $().message("转发失败，请稍后再试！");
                               }
                           };
                           exeAjax(
                                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_transmitFresh${aier_suffix}"),
                                fun,{
                                    "fid":fid,
                                    "content":content,
                                    "cflag":cflag
                           });
                    
                    },"取消": function() {
                        $("#forward").val("");
                        $("#commentFlag").attr("checked",false);
                        $( this ).dialog( "close" );
                    }
                }
            });
            $('#dialogForward').dialog('open');
        });
        
        // 收藏或取消收藏
        $('.btn-favourite').click(function(){
            var thisobj = $(this);
            var fid = thisobj.closest('.xxs-item').attr('data-xxsid');
            
            if (thisobj.hasClass('has-fav')) {
                // 取消收藏
                thisobj.removeClass('has-fav');
                unfavorite(thisobj,fid);
            
            } else {
                // 收藏
                thisobj.addClass('has-fav');
                favorite(thisobj,fid);
            }
        
        });
        // 收藏新鲜事
        function favorite(thisobj,fid) {
            var fun=function(data){
               if(data.s==1){
                   $().message("收藏成功");
                   // 将收藏变为取消收藏
                   thisobj.html("取消收藏");
                   
               } else {
               
                   $().message("收藏失败，请稍后再试！");
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_favoriteFresh${aier_suffix}"),
                fun,{
                    "fid":fid
           });
        }
        // 取消收藏
        function unfavorite(thisobj,fid) {
            var fun=function(data){
               if(data.s==1){
                   $().message("取消收藏成功");
                   // 将取消收藏变为收藏
                   thisobj.html("收藏");
                   
               } else {
                   $().message("取消收藏失败，请稍后再试！");
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_deleteFFByUid${aier_suffix}"),
                fun,{
                    "fid":fid
           });
        }
        
        // 评论
        $('.btn-xxs-comment').click(function(){
            var thisobj = $(this);
            var fid = thisobj.closest('.xxs-item').attr('data-xxsid');
            // 获取新鲜事的评论
            searchComment(fid);
          
            $(this).closest('.xxs-item').find('.xxs-comment').toggle();
            $(this).closest('.xxs-item').find('textarea').focus();
        });
        
        // 评论
        $('.right-submit').click(function(){
            var thisobj = $(this);
            var fid = thisobj.closest('.xxs-item').attr('data-xxsid');
            var content = thisobj.closest('.xxs-item').find('textarea').val();
            var rcontent = thisobj.closest('.xxs-item').find('xxs-text').val();
            var rfcuid = thisobj.closest('.xxs-item').attr('data-xxuid');
            
            if (content.length ==0 ) {
                $().message("评论内容不能为空！");
                return;
            }
            if (content.length > 200) {
                $().message("评论内容太长！");
                return;
            }
            var input = thisobj.closest('.xxs-item').find('input');
            var tflag = 0;
            var cflag = 0;
            if (input.length == 1) {
                if (input.eq(0).attr("checked") == "checked") {
                    tflag = 1;
                }
            } else {
                if (input.eq(0).attr("checked") == "checked") {
                    tflag = 1;
                }
                if (input.eq(1).attr("checked") == "checked") {
                    cflag = 1;
                }
            }
            // 评论
            var fun=function(data){
               if(data.s==1){
                   thisobj.closest('.xxs-item').find('textarea').val("");
                   if (input.length == 1) {
                        input.eq(0).attr("checked",false);
                   } else {
                        input.eq(0).attr("checked",false);
                        input.eq(1).attr("checked",false);
                   }
                   // 刷新评论列表
                   searchComment(fid);
                   // 修改评论的次数
                   thisobj.closest('.xxs-item').find('.btn-xxs-comment ').html("评论("+data.ccount+")");
                   
               } 
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_commentFresh${aier_suffix}"),
                fun,{
                    "fid":fid,
                    "rfcuid":rfcuid,
                    "content":content,
                    "rcontent":rcontent,
                    "ctype":1,
                    "flag":tflag,
                    "cflag":cflag
           });
            
        });
        
    }
    
    // 获取评论列表
    function searchComment(fid) {
        // 获取新鲜事的评论
        var fun=function(data){
           if(data.s==1){
               //fcList
               var html = "";
               if (data.fcList != null && data.fcList.length > 0 ) {
                   for (var i=0;i<data.fcList.length;i++) {
                       var fc = data.fcList[i];
                       html += '<div class="comment-item" data-xxfcuid="'+fc.fcuid+'"><div class="comment-avatar"><a href="${aier_url}user/uccomm_userCenter.shtml?in_uid='+fc.uid+'"><img src="${get_picturl_url}small/'+fc.headimg+'" alt=""></a></div>';
                       html += '<div class="comment-content"><a class="commenter-name"><span class="name">'+fc.nickname+'</span><span>:</span></a><span class="comment-text">'+fc.content+'</span>';
                       html += '<span class="comment-time">('+fc.cdate.split("T")[0]+' '+fc.cdate.split("T")[1]+')</span>';
                       html += '<div class="comment-function clearfix"><div class="right"><a href="javascript:void(0);" class="open-cc">回复</a></div>';
                       html += '<div class="comment-comment" style="display:none;"><div class="cc-textarea"><textarea></textarea></div><div class="cc-submit-bar"><a class="btn-emotion icon-1 icon-1-emotion"></a><label><input type="checkbox">同时转发到我的新鲜事</label><a class="btn-cc-submit btn-orange-2"><span>评论</span></a></div></div></div></div></div>';
                   }
               }
               $("#comment"+fid).html(html);
               // 解析表情
                $('.comment-text').each(function() {
                    $(this).tranText({
                        emotionUrl:'${aier_js_url}trantime/emotions.js'
                    });
                });
               
                // 对评论的回复(动画)
                $('.open-cc').click(function(){
                    $(this).closest('.comment-function').find('.comment-comment').toggle();
                    $(this).closest('.comment-function').find('.comment-comment textarea').focus();
                
                    var thisname = $(this).closest('.comment-content').find('.commenter-name .name').text();
                
                    if (!$(this).closest('.comment-function').find('.comment-comment textarea').val() ) {
                        $(this).closest('.comment-function').find('.comment-comment textarea').val("回复@"+thisname+":");
                    };
                    openCCClick();
                    
                });
                // 回复
                $('.btn-cc-submit').click(function() {
                     var fid = $(this).closest('.xxs-item').attr('data-xxsid');
                     var content = $(this).closest('.comment-function').find('.comment-comment textarea').val();
                     var rfcuid = $(this).closest('.comment-item').attr('data-xxfcuid');
                     var rcontent = $(this).closest('.comment-item').find('.comment-text').html();
                     
                     if (content.substring(content.indexOf(":")+1).length == 0) {
                         $().message("回复内容不能为空！");
                         return;
                     }
                     if (content.length > 200) {
                        $().message("回复内容太长！");
                        return;
                     }
                     
                     var input = $(this).closest('.comment-comment').find('input');
                     var tflag = 0;
                     if (input.attr("checked") == "checked") {
                        tflag = 1;
                     }
                     var thisobject = $(this);
                     var fun=function(data){
                       if(data.s==1){
                           thisobject.closest('.comment-function').find('.comment-comment textarea').val("");
                           input.attr("checked",false);
                           // 修改评论的次数
                           thisobject.closest('.xxs-item').find('.btn-xxs-comment ').html("评论("+data.ccount+")");
                           // 刷新评论列表
                           searchComment(fid);
                   
                       } 
                   };
                   exeAjax(
                        ajaxUrl("${aier_url}${aier_urijs}userhomeforums_commentFresh${aier_suffix}"),
                        fun,{
                            "fid":fid,
                            "rfcuid":rfcuid,
                            "content":content,
                            "rcontent":rcontent,
                            "ctype":2,
                            "flag":tflag
                   });
                });
           } 
       };
       exeAjax(
            ajaxUrl("${aier_url}${aier_urijs}userhomeforums_searchCommentByFid${aier_suffix}"),
            fun,{
                "fid":fid
       });
    }
 
    // 删除微博
    function deleteFresh(fid) {
        $(function() {
            $("#deleteConfirm").dialog(
                {
                    //背景变暗
                    modal : true,
                    autoOpen : false,
                    show : "fade",
                    hide : "fade",
                    width : "340",
                    height : "220",
                    buttons : {
                        "确定" : function() {
                            // 获取新鲜事列表
                            var fun=function(data){
                                if(data.s==1){
                                    $("#deleteConfirm").dialog("close");
                                    searchAllFresh();
                                } else {
                                    $("#deleteConfirm").dialog("close");
                                    $().message("删除失败，请稍后再试！");
                                }
                                
                            };
                            exeAjax(
                                 ajaxUrl("${aier_url}${aier_urijs}userhomeforums_deleteFresh${aier_suffix}"),
                                 fun,{
                                    "fid":fid
                            });
                                            },
                        "取消" : function() {
                            $(this).dialog("close");
                        }
                }
            });
            $("#deleteConfirm").dialog("open");
        });
        
    }
    
    function searchSComment() {
        var fun=function(data){
               if(data.s==1){
                   $("#msgSpecialComment").html("");
                   appendComment(data.fcList);
                   // 更新分页显示
                   cpage = data.page;
                   toLoadPage(cpage, page_size, data.page_count, data.count, "page", "searchSComment", null, null);
                   if (data.count == 0) {
                       $("#page").css("display","none");
                   } else {
                       $("#page").css("display","block");
                   }
                   
               } else {
                   $().message("获取评论失败，请稍后再试！"); 
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}usermessage_searchSpecialComment${aier_suffix}"),
                fun,{
                    "page":cpage,
                    "page_size":page_size
           });
    }
    
    function appendComment(fcList) {
    	var html = "";
        if (fcList == null || fcList.length == 0) {
            html += '<div class="msg-at-comment-num">暂时没有评论@你</div>';
        } else {
            html += '<div class="msg-at-comment-num">共'+fcList.length+'条</div>';
            html += '<div class="message-stream-list child-message-list clearfix">';
            for (var i=0; i<fcList.length; i++) {
                var fc = fcList[i];
                html += '<div class="msg-at-comment-item" data-xxfcuid="'+fc.fcuid+'" data-fid="'+fc.fid+'"><div class="avatar"><a href="${aier_url}user/uccomm_userCenter.shtml?in_uid='+fc.fcuid+'"><img src="${get_picturl_url}small/'+fc.headimg+'" alt=""></a></div>';
                html += '<div class="detail"><div class="content"><a class="username">'+fc.nickname+'</a>:<span class="content-text">'+fc.content+'</span></div><div class="related-xxs">';
                
                if (fc.type = 1) {
                    html += '<span>评论<a class="text"> '+fc.rnickname+'</a> 的微博</span>:';
                } else {
                    html += '<span>回复<a class="text"> '+fc.rnickname+'</a> 的评论</span>:';
                }
                html += '<a class="text">'+fc.rcontent+'</a></div><div class="function clearfix"><div class="left">'+fc.cdate.split("T")[0]+' '+fc.cdate.split("T")[1]+'</div>';
                html += '<div class="right"><a class="reply">回复</a></div></div>';
                html += '<div class="comment" style="display:none;"><div class="input-box"><div class="textarea-bar"><textarea name="" id="" class="comment-textarea" data-id="123"></textarea></div>';
                html += '<div class="submit-bar clearfix"><div class="submit-bar"><a class="icon-1 icon-1-emotion btn-emotion"></a></div>';
                html += '<div class="right-submit"><a class="btn-orange-2"><span>评论</span></a></div></div></div></div></div></div>';
            
            }
            html += '</div>';
        }
        $("#msgSpecialComment").html(html);
        $("#msgSpecialComment .text").each(function(){
            $(this).tranText({
                emotionUrl: '${aier_js_url}trantime/emotions.js'
            });
        });
        $("#msgSpecialComment .content-text").each(function(){
            $(this).tranText({
                emotionUrl: '${aier_js_url}trantime/emotions.js'
            });
        });
        
        emotionClick();
        
        $('.reply').click(function(){
            var thisname = $(this).closest('.msg-at-comment-item').find('.username').text();
            var targetComment = $(this).closest('.function').next('.comment');
            var targetArea = $(this).closest('.function').next('.comment').find('textarea');
            targetComment.toggle();
            targetArea.focus();
            targetArea.text('回复'+'@'+thisname+':');
        });
        
        // 回复
        $('.right-submit').click(function() {
             var content = $(this).closest('.comment').find('textarea').val();
             var rcontent = $(this).closest('.msg-at-comment-item').find('.content-text').html();
             var fid = $(this).closest('.msg-at-comment-item').attr('data-fid');
             var rfcuid = $(this).closest('.msg-at-comment-item').attr('data-xxfcuid');
             
             if (content.substring(content.indexOf(":")+1).length == 0) {
                 $().message("回复内容不能为空！");
                 return;
             }
             if (content.length > 200) {
                $().message("回复内容太长！");
                return;
             }
             
             var thisobject = $(this);
             var fun=function(data){
               if(data.s==1){
                   thisobject.closest('.comment').find('textarea').val(content.substring(0,content.indexOf(":")+1));
                   $().message("回复成功！");
               } else {
                   $().message("回复失败，请稍后再试！");
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_commentFresh${aier_suffix}"),
                fun,{
                    "fid":fid,
                    "rfcuid":rfcuid,
                    "content":content,
                    "rcontent":rcontent,
                    "ctype":2,
                    "flag":0
           });
        });
    
    }
    
    // 跳转到家校联系薄
    function hsConBook() {
        // 判断是否付费

        // 判断身份（家长或老师）

        // 教师（tid）
        //window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?tid=2&&cid=1";
        var fun = function(data) {
            if (data.s == 1) {

                if (data.type == 0) {
                    $().message("您目前没有权利进入家校联系薄！");
                    return;
                } else if (data.type == 1 || data.type == 3) {
                    if (data.classList != null && data.classList.length > 0) {
                        window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?cid="
                                + data.classList[0].cid +"&type="+data.type;
                    } else {
                        window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?type="+data.type;
                    }

                } else if (data.type == 2) {
                    window.location.href = "${aier_url}user/userhscb_userChiHSConBook.shtml?type="+data.type;
                }

            }
        };
        exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhscb_searchClassList${aier_suffix}"),
                fun, {});

    }


</script>

</body>
</html>